<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>医生登录</title>
    <link rel="stylesheet" href="/static/bootstrap-5.3.0/css/bootstrap.css">
</head>
<body onload="loadForm()">
<form style="width: 400px; margin: 200px auto" method="post">
    <div class="mb-3">
        <label for="doctorId" class="form-label">请输入医师号</label>
        <input type="text" class="form-control" id="doctorId" aria-describedby="idHelp" name="doctorId">
        <div id="idHelp" class="form-text">请注意不要泄露密码给患者</div>
    </div>
    <div class="mb-3">
        <label for="doctorName" class="form-label">请输入医生姓名</label>
        <input type="text" class="form-control" id="doctorName" name="doctorName">
    </div>
    <div class="mb-3">
        <label for="doctorPassword" class="form-label">请输入密码</label>
        <input type="password" class="form-control" id="doctorPassword" name="doctorPassword">
    </div>
    <div class="mb-3 form-check">
        <input type="checkbox" class="form-check-input" id="exampleCheck1" onclick="saveForm()">
        <label class="form-check-label" for="exampleCheck1">记住我</label>
    </div>
    <button type="submit" class="btn btn-primary">提交</button>
</form>

<script>
    function saveForm() {
        if (document.getElementById('exampleCheck1').checked) {
            localStorage.setItem('doctorId', document.getElementById('doctorId').value);
            localStorage.setItem('doctorName', document.getElementById('doctorName').value);
            localStorage.setItem('doctorPassword', document.getElementById('doctorPassword').value);
        } else {
            localStorage.removeItem('doctorId');
            localStorage.removeItem('doctorName');
            localStorage.removeItem('doctorPassword');
        }
    }

    function loadForm() {
        const doctorId = localStorage.getItem('doctorId');
        const doctorName = localStorage.getItem('doctorName');
        const doctorPassword = localStorage.getItem('doctorPassword');

        if (doctorId && doctorName && doctorPassword) {
            document.getElementById('doctorId').value = doctorId;
            document.getElementById('doctorName').value = doctorName;
            document.getElementById('doctorPassword').value = doctorPassword;
            document.getElementById('exampleCheck1').checked = true;
        }
    }
</script>
</body>
</html>
